package com.peng.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.peng.mapper.TeacherMapper;
import com.peng.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class TeacherServiceImp implements TeacherService {
    @Autowired
    private TeacherMapper teacherMapper;

    @Override
    public PageInfo<User> selectTeacherAll(String username, Integer page, Integer size) {
        if (page != null & size != null) {
            PageHelper.startPage(page, size);
        }
        return new PageInfo<>(teacherMapper.selectTeacherAll(username));
    }

    @Override
    public boolean addTeacher(User user) {
        teacherMapper.addTeacher(user);
        return true;
    }

    @Override
    public int updateTeacherStatus(int status, Integer... id) {
        if (status == 3) {
            //articleMapper.updateArticleStatus(status,id);
            //welfareCastleMapper.updateWelfareCastleStatus(status,id);
            //openCourseService.updateOpenCourseStatus(status,id);
            return teacherMapper.updateTeacherStatus(status, id);
        }
        return teacherMapper.updateTeacherStatus(status, id);
    }

    @Override
    public boolean deleteTeacherById(Integer... id) {
        //openCourseService.deleteOpenCourse(id);
        teacherMapper.deleteTeacherById(id);
        return true;
    }
}
